<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>定位</title>
		<style type="text/css">
			*{
				padding: 0;
				margin: 0;
			}
			.box1{
				/* width: 300px; */
				height: 200px;
				background-color: hotpink;
				position: fixed;		/* 固定定位fixed脱标 */
				z-index: 100;
			}
			.box2{
				width: 300px;
				height: 200px;
				background-color: green;
				position: relative;		/* 相对定位relative不脱标 */
				/* position: absolute; */
				/* top: 10px; */
				/* bottom: 10px;*/
				/* left: 10px; */
				padding: 30px;
				background-clip: content-box;
				border: 2px solid black;
			}
			.box3{
				width: 300px;
				height: 200px;
				background-color: yellow;
			}
			/* 子级盒设置绝对定位absolute,父级盒设置相对定位relative;"子绝父相"*/
			/* 通过top,right,bottom,left调整相对位置 */
			.box4{
				width: 100px;
				height: 100px;
				background-color: blue;
				border: 2px solid red;
				position: absolute;		/* 绝对定位之后脱标的 */
				top: 10px;
				left: 50%;
				margin-left: -50px;
				
			}
			.box5{
				border: 2px solid red;
				width: 200px;
				display: block;
				text-align: center; 
			}
			.box6{
				border: 2px solid #008000;
				float: right;
				
			}
		</style>
	</head>
	<body>
		<div class="box1"></div>
		<div class="box2">
			<div class="box4"></div>
		</div>
		<div class="box3"></div>
		<div class="box5">
			<div class="box6"></div>
		</div>
		
	</body>
</html>
